<template>
  <the-table :columns="columns" uri="/a/balances" :slots="['balance']">
    <span
      slot="balance"
      slot-scope="{ row }"
      :class="row.value > 0 ? 'blue' : 'red'"
      >{{ row.value > 0 ? '+' : '' }} {{ row.value }}</span
    >
  </the-table>
</template>
<script>
import theTable from '@/components/theTable.vue'

const columns = [
  {
    title: 'ID',
    dataIndex: 'id',
  },
  // {
  //   title: '商户名',
  //   dataIndex: 'seller.username',
  //   searchAble: true,
  // },
  {
    title: '用户名',
    // dataIndex: 'member.username',
    dataIndex: 'user.username',
    searchAble: true,
  },
  {
    title: '用户类型',
    dataIndex: 'role',
    visible: false,
    searchAble: true,
    dataType: 'select',
    search: {
      selectOptions: [
        { title: '商户', value: 'seller' },
        { title: '用户', value: 'member' },
        { title: '代理', value: 'agent' },
      ],
    },
  },
  {
    title: '类型',
    dataIndex: 'type',
    searchAble: true,
    width: 300,
    dataType: 'select',
    search: {
      selectOptions: [
        '商户卖币(人工)',
        '商户卖币(接口)',
        '商户卖币手续费',
        '商户卖币扣奖励',
        '人工加币',
        '人工减币',
        '用户卖币',
        '用户卖币被拒',
        '商户买币',
        '用户买币',
        '用户买币佣金',
        '用户买币奖励',
        '代理佣金',
        '代理奖励',
        '提取佣金',
        '异常订单被扣',
      ].map((str) => {
        return {
          title: str,
          value: str,
        }
      }),
    },
  },
  {
    title: '变化值',
    dataIndex: 'value',
    scopedSlots: { customRender: 'balance' },
  },
  {
    title: '变化前',
    dataIndex: 'b4',
  },
  {
    title: '变化后',
    dataIndex: 'after',
  },
  {
    title: '创建时间',
    dataIndex: 'created_at',
  },
  {
    title: '订单号',
    dataIndex: 'order_id',
  },
]

export default {
  components: { theTable },

  data() {
    return {
      columns,
    }
  },
  mounted() {},
  methods: {},
}
</script>
